<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style>
		table,div{
			width:600px;
			margin: 0 auto;
		}
		table td{
			padding:3px 5px;
			border:1px solid #ccc;
		}
	</style>
</head>
<body>
	<div>
		<a href='add.php'>添加</a>
	</div>
	
	<table>
		<tr>
			<td>封面</td>
			<td>标题</td>
			<td>作者</td>
			<td>内容</td>
			<td>备注</td>
			<td>操作</td>
		</tr>

		<?php
			session_start();
			if(!$_SESSION['IsLogin'] || $_SESSION['IsLogin']!='true'){
				echo "<script>alert('登录超时或未登录，请先登录！');location.href='./Login.php';</script>";
			}
		
		
			include "db.php";
			$data = mysqli_query($conn,"select * from Articles;");
			// 获取一行记录
			$row = mysqli_fetch_array($data);
			// 如果获取的记录是非空的，通过表格显示出来
			while($row){ 
				// $row有数据,执行大括号里面的内容
				
				// echo <<<shi
				// <tr>
				// 	<td>{$row['Title']}</td>
				// 	<td>{$row['Author']}</td>
				// 	<td>{$row['Content']}</td>
				// 	<td>{$row['Remark']}</td>
				// 	<td><a>编辑</a><a>删除</a></td>
				// </tr>
				// shi;
				
				// 显示表格
				echo "<tr>";
				// echo "<td>".$row['Title']."</td>";
				if($row['Photo']==''){
					echo '<td></td>';
				}else{
					echo "<td><img width='80px' src='./images/${row['Photo']}'/></td>";
				}
				echo "<td>${row['Title']}</td>";
				echo "<td>${row['Author']}</td>";
				echo "<td>${row['Content']}</td>";
				echo "<td>${row['Remark']}</td>";
				echo "<td><a href='./edit.php?id=${row['ArticleId']}'>编辑</a>&nbsp;<a href='./delete.php?id=${row['ArticleId']}'>删除</a></td>";
				echo "</tr>";
				// 获取下一行记录
				$row = mysqli_fetch_array($data);
			}
		
		?>
	</table>
	
</body>
</html>